/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Collection;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.persistence.*;

/**
 *
 * @author weidas
 */
@ManagedBean
@RequestScoped
public class LoginBean {

    private String name;
    private String password;
    //RomaCommunityv1PU
    EntityManagerFactory fac = Persistence.createEntityManagerFactory("RomaCommunityv1PU");
    //EntityManagerFactory emf = this.session = HibernateUtil.getSessionFactory().getCurrentSession();

    /** Creates a new instance of LoginBean */
    public LoginBean() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    
    public String Validate(){
        EntityManager m = fac.createEntityManager();
        
        DB.User u = m.find(DB.User.class, 1);
        Query f = m.createNamedQuery("User.findById");
        f.setParameter("id", 1);
        Collection<DB.User> c = f.getResultList();
        
        return "true";
    }
    
    
}
